package com.lidong;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@RestController
public class SpringcloudsoftServiceMiyaApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringcloudsoftServiceMiyaApplication.class, args);
	}
	
	private static final Logger LOGGER = LoggerFactory.getLogger(SpringcloudsoftServiceMiyaApplication.class);
	
	@Autowired
    private RestTemplate restTemplate;

    @Bean
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }
	
	@RequestMapping("/say")
    public String say(){
		LOGGER.info("Say() is being called!!!");
        return "Hi, I'm miya!";
    }

    @RequestMapping("/info")
    public String info(){
    	LOGGER.info("Info is being called!!!");
        return restTemplate.getForObject("http://localhost:8102/info",String.class);
    }

	
}
